package com.task.scheduling.service.impl;

import com.task.scheduling.dao.TaskSchedulingDao;
import com.task.scheduling.model.TaskSchedulingModel;
import com.task.scheduling.service.TaskSchedulingService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Date;
import java.util.List;
@Service
public class TaskSchedulingServiceImpl implements TaskSchedulingService{


	private Logger log = LoggerFactory.getLogger(TaskSchedulingServiceImpl.class);

	@Autowired
	private TaskSchedulingDao taskSchedulingDao;

	@Override
	public Long save(TaskSchedulingModel model) {
		 taskSchedulingDao.addTask(model);
		return model.getId();
	}

	@Override
	public int updateTaskSchedule(TaskSchedulingModel model) {
		return taskSchedulingDao.updateTaskSchedule(model);
	}



	@Override
	public TaskSchedulingModel getNewTask(Date now, int seconds, List<Long> ids) {
		return taskSchedulingDao.getNewTask(now, seconds, ids);
	}

	@Override
	public List<String> getAllExecutors() {
		return taskSchedulingDao.getAllExecutors();
	}

	@Override
	public TaskSchedulingModel selectById(Long id) {
		return taskSchedulingDao.getTaskById(id);
	}
}
